/*
 * @Author: zzy 917106840648 NJUST
 * @Date: 2020-03-24 08:55:51
 * @LastEditTime: 2020-04-04 13:27:58
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \W+compiler\src\w+compiler.cpp
 */
#include "..\include\LexicalAnalyzer.h"
#include "..\include\SemanticAnalyzer.h"
#include "..\include\SyntacticAnalyzer.h"

int main(int argc, char const* argv[])
{
    cout << "请选择模式: 1.词法分析器 2.语法分析器 3.词法+语法 4.词法+语义分析 "
            "5.语义分析"
         << endl;
    cout << "请输入 : ";
    int n;
    cin >> n;

    if (n == 1) {
        Nfa nfa;
        nfa.run();
        Dfa dfa;
        NFA2DFA(nfa, dfa);
        dfa.run();
        fileOpen();
        analyze(dfa);
        fileClose();
    }
    else if (n == 2) {
        Lr lr;
        LfileOpen();
        lr.run();
        LfileClose();
    }
    else if (n == 3) {
        Nfa nfa;
        nfa.run();
        Dfa dfa;
        NFA2DFA(nfa, dfa);
        dfa.run();
        fileOpen();
        analyze(dfa);
        fileClose();

        Lr lr;
        LfileOpen();
        lr.run();
        LfileClose();
    }
    else if (n == 4) {
        // cout << "LRS" << endl;
        Nfa nfa;
        nfa.run();
        Dfa dfa;
        NFA2DFA(nfa, dfa);
        dfa.run();
        fileOpen();
        analyze(dfa);
        fileClose();

        LrS lrs;
        LfileOpen_S();
        lrs.run();
        LfileClose_S();
        return 0;
    }
    else if (n == 5) {
        LrS lrs;
        LfileOpen_S();
        lrs.run();
        LfileClose_S();
        return 0;
    }
    else {
        cout << "input Error" << endl;
        exit(0);
    }

    return 0;
}
